<template>
  <!-- mv组件 -->
  <div class="mv_wrapper">
    <div class="top_img_wrap cursor_class" @click="router.push('/discover/mvs-detail/' + id)">
      <img :src="picUrl" alt="">
      <div class="play_time">
        <el-icon :size="16"><VideoCamera /></el-icon>
        &nbsp;{{ formatNumber(playTime, 100000, 1) }}
      </div>
      <div class="durationms">{{ dayjs(durationms).format("mm:ss") }}</div>
    </div>
    <div class="bottom_info">
      <div class="mv_name_wrapper">
        <el-tag>MV</el-tag>
        <div class="mv_name text_ellipsis text_decoration cursor_class" @click="router.push('/discover/mvs-detail/' + id)">{{ name }}</div>
      </div>
      <div class="mv_singer text_ellipsis">
        <span v-for="(item,index) in singers">
            <span v-if="index != 0" style="margin: 0 4px">/</span>
            <span class="text_ellipsis text_decoration cursor_class" @click="router.push('/discover/artist-detail/' + item.userId)">{{ item.userName }}</span>
        </span>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { onMounted, reactive, ref } from "vue"
import { defineEmits, defineProps, toRefs } from 'vue'
import { VideoCamera } from '@element-plus/icons-vue'
import router from '@/router';
import { formatNumber } from "@/utils/index";
import dayjs from "dayjs";
const emit = defineEmits([])
const props = defineProps({
  picUrl: {
    type: String,
    default: ''
  },
  // mvid
  id: {
    type: Number,
    default: 0,
    require: true
  },
  // mv名字
  name: {
    type: String,
    default: ''
  },
  // 歌手
  singers: {
    type: Array,
    default: () => {
      return []
    }
  },
  // 播放量
  playTime: {
    type: Number,
    default: 0
  },
  // 时长
  durationms: {
    type: Number,
    default: 0
  }
})
const { picUrl, id, name, playTime, durationms } = toRefs(props)
onMounted(() => {
})
</script>
<style lang="scss" scoped>
.mv_wrapper {
  .top_img_wrap {
    height: 120px;
    position: relative;
    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .play_time {
      position: absolute;
      top: 0;
      right: 0;
      padding: 3px 5px;
      color: #fff;
      font-size: 12px;
      display: flex;
      align-items: center;
      background-color: rgba(0, 0, 0, 0.4);
    }
    .durationms {
      position: absolute;
      bottom: 0;
      left: 0;
      padding: 3px 5px;
      color: #fff;
      font-size: 12px;
    }
  }

  .bottom_info {
    // margin: 10px 0 0;
    .mv_name_wrapper {
      display: flex;
      overflow: hidden;
      align-items: center;
      margin: 10px 0  4px;
      .mv_name {
        font-size: 12px;
        margin-left: 10px;
        flex: 1;
      }
    }
    .mv_singer {
      span {
        color: #666;
        font-size: 12px;
      }
    }
  }
}
</style>
